#include("../../comm/ListHead.html")
<div class="layui-fluid layui-anim layui-anim-scale">
    <div class="layui-row layui-col-space5">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="card-search SearchTable">
                    <p style="float:right">
                        <input type="text" id="post_name" placeholder="岗位名称" class="table-search-text width200"/>

                        <button class="layui-btn layui-btn-warm layui-btn-sm" lay-event="DoSearch">
                            搜索
                        </button>

                    </p>
                    <i class="layui-icon layui-icon-user"></i>
                    <span class="color_green">员工工作岗位列表</span>
                </div>
                <div class="layui-card-body">
                    <table class="layui-hide" id="table_1" lay-filter="table_1"></table>

                    <script type="text/html" id="table_1_bar_title">
                        <div class="layui-btn-container" style="float:left">
                            <button class="layui-btn layui-btn-sm btn-add" lay-event="AddSysPost">
                                <i class="layui-icon">&#xe608;</i> 添加系统岗位
                            </button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-edit" lay-event="EditSysPost">修改</button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-del" lay-event="DelSysPost">删除</button>
                        </div>
                        <div id="bar_desc"></div>
                    </script>


                </div>
            </div>
        </div>
    </div>
</div>
<script language="JavaScript">

    layui.use(['myTable', 'table', 'form', 'util', 'myTool', 'drawer'], function () {
        var $ = layui.$, myTable = layui.myTable, myTool = layui.myTool;
        /**
         * 表格
         */
        tableindex = layui.myTable.render({
            elem: '#table_1', url: 'SysPostListDataApi'
            , title: '系统岗位列表'
            , where: {}
            , cols: [[
                {type: 'checkbox', width: 36, fixed: true}
                , {field: 'post_id', title: '岗位ID', width: 100, align: 'center', sort: true}
                , {field: 'sindex', title: '顺序', width: 100, edit: 'text', align: 'center'}
                , {field: 'post_name', title: '岗位名称', width: 200}
                , {field: 'post_desc', title: '岗位描述'}

            ]]
            , page: true, limit: 10
            , serviceSort: true, initSort: {field: 'post_id', type: 'desc'}
            , editField: {url: 'ModifySysPostFieldApi', key: 'post_id'}
            , done: function (res, curr, count) {
                $("#bar_desc").html("");
            }
        });


        /**
         * 按钮事件
         */
        layui.util.event("lay-event", {
            DoSearch: function () {
                tableindex.config.where = {s: {post_name: $("#post_name").val()}};
                tableindex.reload({where: tableindex.config.where, page: {curr: 1}});
            }
            , DoSearchMore: function () {
                layui.form.render();
                drawer1.open();
            }
        });

        /**
         * 工具栏事件
         */
        layui.table.on('toolbar(table_1)', function (obj) {
            myTool.toolbar(this, obj, {
                AddSysPost: function () {
                    index = top.layer.open({
                        type: 2, offset: '60px', area: ['700px', '520px'], title: ['添加系统岗位', 'font-size:15px;'],
                        content: ["syspost/AddSysPost", 'no'],
                        end: function () {
                            tableindex.reload({});
                        }
                    });
                }
                , EditSysPost: function () {
                    myTool.doSingleSelect(layui.myTable.checkStatus('table_1'), {}, function (data, keys) {
                        index = top.layer.open({
                            type: 2, offset: '60px', area: ['700px', '520px'], title: ['修改系统岗位[' + data[0].post_id + ']', 'font-size:15px;'],
                            content: ["syspost/EditSysPost?post_id=" + data[0].post_id, 'no'],
                            end: function () {
                                tableindex.reload({});
                            }
                        });
                    });
                }
                , DelSysPost: function () {
                    myTool.doSingleSelect(layui.myTable.checkStatus('table_1'), {}, function (data, keys) {
                        index = top.layer.confirm('你是否确认删除系统岗位【' + data[0].post_id + '】', {icon: 3, title: '提示', offset: '150px'}, function (index2) {
                            myTool.postMsg("DelSysPostApi", {
                                post_id: data[0].post_id
                            }, function () {
                                top.layer.close(index2);
                                tableindex.reload();
                            });
                        });
                    });
                }, DelMoreSysPost: function () {
                    myTool.doMoreSelect(layui.myTable.checkStatus('table_1'), {key: 'post_id'}, function (data, keys) {
                        index = top.layer.confirm('你是否确认批��删除选中的系统岗位【' + data.length + '】数据', {icon: 3, title: '提示', offset: '150px'}, function (index2) {
                            myTool.postMsg("DelMoreSysPostApi", {keys: keys}, function () {
                                top.layer.close(index2);
                                tableindex.reload();
                            });
                        });
                    });
                }
            });
        });


        layui.form.on('checkbox(ChangeSysPostTag)', function (obj) {
            myTool.postMsg("ChangeTagSysPostApi", {key: this.value, field: $(obj.elem).attr("field"), msg: $(obj.elem).attr("msg")}, function (result) {
                layer.tips(result.msg, obj.othis);
            });
        });
        layui.form.on('switch(ChangeSysPostTag)', function (obj) {
            myTool.postMsg("ChangeTagSysPostApi", {key: this.value, field: $(obj.elem).attr("field"), msg: $(obj.elem).attr("msg")}, function (result) {
                layer.tips(result.msg, obj.othis);
            });
        });
    });
</script>
#include("../../comm/Foot.html")